﻿@model Wicresoft.SelfService.DAO.ServiceDetail
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/swfobject.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.uploadify.v2.1.4.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/uploadFiles.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/create.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/approveActions.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/popupWindows.js")" type="text/javascript"></script>
@{    
    string serviceName = string.Empty;
    string partialName = string.Empty;
    if (Model != null && Model.serviceType != null) { serviceName = Model.serviceType.serviceName; partialName = Model.serviceType.partialName; }
    ViewBag.Title = "IT服务申请更新 - " + @Model.serviceRequestID;
    Layout = "~/Views/Shared/_DetailLayout.cshtml";
}
@using (Html.BeginForm())
{
    if (Model == null)
    {
    <p>
        该申请单不存在，或者您没有权限访问。</p>
    }
    else
    { 
    <div class="center_box_bg">
        <div class="ChannelTitle">
            <h2>@serviceName</h2>
        </div>
        <div class="line_top">
            <table>
                <tr>
                    <td>
                        <input type="button" id="backBtn" class="Button1 ui-icons subForward" value="返回上一页" />
                    </td>
                    <td style="width: 100%;">
                        <input class="Button1 ui-icons subForward" title="提交该申请至下一审批人" value="提交" type="submit"
                            name="action" />
                        <input class="Button1 ui-icons subSave" title="保存该申请单" value="保存" type="submit" name="action" />
                        @if (Model.stauts == 5)
                        {
                            <input class="Button1 ui-icons btnViewSuggestion" title="查看审批意见" value="意见" type="button" />
                        }
                    </td>
                </tr>
            </table>
        </div>
        <div class="box_padding">
            @Html.HiddenFor(model => model.serviceRequestID, Model.serviceRequestID)
            @Html.ValidationSummary(true)
            @Html.Partial("UserInfo", Model)
            @Html.Partial(partialName, Model)
        </div>
        <div class="line_top">
            <input class="Button1 ui-icons subForward" title="提交该申请至下一审批人" value="提交" type="submit"
                name="action" />
            <input class="Button1 ui-icons subSave" title="保存该申请单" value="保存" type="submit" name="action" />
            @if (Model.stauts == 5)
            { 
                <input class="Button1 ui-icons btnViewSuggestion" title="查看审批意见" value="意见" type="button" />
            }
        </div>
    </div>    
    <div id="greybackground">
    </div>
    <div class="popupWindow">
        <table border="0" cellpadding="0" cellspacing="0" class="INFORM_BOX">
            <tbody>
                <tr>
                    <td class="tdShadow">
                        <table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                                <tr>
                                    <td class="tdBorder">
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tbody>
                                                <tr>
                                                    <td class="tdTitle">
                                                        意见
                                                    </td>
                                                    <td align="right" class="btnFields">
                                                        <input class="Button1 ui-icons" id="btnCloseSuggestion" title="关闭" value="关闭" type="button" />
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                        <table id="tbViewSuggestions" class="border_line" width="100%" border="0" cellpadding="0"
                                            cellspacing="0">
                                            <tbody>
                                            </tbody>
                                        </table>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>  
    }
}
<script type="text/javascript">
    $(function () {
        $('#breakDownlvl1').bind('click', { selectID: 'breakDownlvl1' }, defaultClickEvent);
        $('#breakDownlvl2').bind('click', { selectID: 'breakDownlvl2' }, defaultClickEvent);
        $('#breakDownlvl3').bind('click', { selectID: 'breakDownlvl3' }, defaultClickEvent);
        $('#appCategory').bind('click', { selectID: 'appCategory' }, defaultClickEvent);
        $('#appName').bind('click', { selectID: 'appName' }, defaultClickEvent);
        function defaultClickEvent(e) {
            switch (e.data.selectID) {
                case 'breakDownlvl1':
                    $.ajax({
                        url: "getlvl1",
                        type: "GET",
                        success: function (data) {
                            if ($("#breakDownlvl1 option").length > 1) $("#breakDownlvl1").empty();
                            $.each(data, function (i, item) {
                                if (item.ID != $("#breakDownlvl1 option:selected").val()) {
                                    $("#breakDownlvl1").append("<option value='" + item.ID + "'>" + item.LvlName + "</option>");
                                }
                            });
                        }
                    });
                    $('#breakDownlvl1').unbind('click', defaultClickEvent);
                    break;
                case 'breakDownlvl2':
                    $.ajax({
                        url: "getlvl2",
                        type: "GET",
                        data: { "id": $("select#breakDownlvl1 option:selected").val(), "categoryText": $("select#breakDownlvl1 option:selected").text(), "company": $("input#account_company").val() },
                        success: function (data) {
                            if ($("#breakDownlvl2 option").length > 1) $("#breakDownlvl2").empty();
                            $.each(data, function (i, item) {
                                if (item.ID != $("#breakDownlvl2 option:selected").val()) {
                                    $("#breakDownlvl2").append("<option value='" + item.ID + "'>" + item.LvlName + "</option>");
                                }
                            });
                        }
                    });
                    $('#breakDownlvl2').unbind('click', defaultClickEvent);
                    break;
                case 'breakDownlvl3':
                    $.ajax({
                        url: "getlvl3",
                        type: "GET",
                        data: { "id": $("select#breakDownlvl2 option:selected").val(), "categoryText": $("select#breakDownlvl1 option:selected").text() },
                        success: function (data) {
                            if ($("#breakDownlvl3 option").length > 1) $("#breakDownlvl3").empty();
                            $.each(data, function (i, item) {
                                if (item.ID != $("#breakDownlvl3 option:selected").val()) {
                                    $("#breakDownlvl3").append("<option value='" + item.ID + "'>" + item.LvlName + "</option>");
                                }
                            });
                        }
                    });
                    $('#breakDownlvl3').unbind('click', defaultClickEvent);
                    break;
                case 'appCategory':
                    $.ajax({
                        url: "getAppCategory",
                        type: "GET",
                        data: { "company": $("input#account_company").val() },
                        success: function (data) {
                            if ($("select#appCategory option").length > 1) $("select#appCategory").empty();
                            $.each(data, function (i, item) {
                                if (item.category != $("select#appCategory option:selected").val()) {
                                    $("select#appCategory").append("<option value='" + item.category + "'>" + item.category + "</option>");
                                }
                            });
                        }
                    });
                    $('select#appCategory').unbind('click', defaultClickEvent);
                    break;
                case 'appName':
                    $.ajax({
                        url: "getAppSystem",
                        type: "GET",
                        data: { "category": $("select#appCategory option:selected").val(), "company": $("input#account_company").val() },
                        success: function (data) {
                            if ($("select#appName option").length > 1) $("select#appName").empty();
                            $.each(data, function (i, item) {
                                if (item.Name != $("select#appName option:selected").val()) {
                                    $("select#appName").append("<option value='" + item.Name + "'>" + item.Name + "</option>");
                                }
                            });
                        }
                    });
                    $('select#appName').unbind('click', defaultClickEvent);
                    break;
                default:
                    break;
            }
        }
    });
</script>
